package com.lijin.study.java.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import org.junit.Test;


public class DateTest {

	@Test
	public void testDtFmt() throws ParseException {
		DateFormat format = new SimpleDateFormat("yyyyMMdd");
		System.out.println(format.parse("20110321"));
		Calendar c = Calendar.getInstance();
		c.setTime(format.parse("20110321"));
		
		c.add(Calendar.DAY_OF_YEAR, -1);
		c.set(Calendar.HOUR, 23);
		c.set(Calendar.MINUTE, 59);
		c.set(Calendar.SECOND, 59);
		
		System.out.println(c.get(Calendar.DAY_OF_MONTH));
		System.out.println(c.get(Calendar.DAY_OF_WEEK));
		System.out.println(c.get(Calendar.DAY_OF_YEAR));
		System.out.println(c.get(Calendar.DAY_OF_WEEK_IN_MONTH));
		System.out.println(c.get(Calendar.HOUR));
		System.out.println(c.get(Calendar.MINUTE));
		System.out.println(c.get(Calendar.SECOND));
		
		System.out.println(c.getTime());
	}
}
